package com.vessel.decoration.mvp.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.vessel.decoration.BuildConfig;
import com.vessel.decoration.R;
import com.vessel.decoration.app.base.MySupportAdapter;
import com.vessel.decoration.app.data.entity.ArtisanInfoResponse;
import com.vessel.decoration.app.utils.UiHelper;

public class ArtisanAdapter extends MySupportAdapter<ArtisanInfoResponse.SkillsBean> {

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_shop_product, null);
            viewHolder.chaptersPic = UiHelper.find(convertView, R.id.product_ic);
            viewHolder.name = UiHelper.find(convertView, R.id.product_name);
            viewHolder.remark = UiHelper.find(convertView, R.id.product_remark);
            viewHolder.price = UiHelper.find(convertView, R.id.price);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Glide.with(parent.getContext()).load(BuildConfig.APP_DOMAIN + getItem(position).getSkillPic()).into(viewHolder.chaptersPic);
        viewHolder.name.setText(getItem(position).getSkillName());
        viewHolder.remark.setText(getItem(position).getRemark());
        viewHolder.price.setText("¥" + getItem(position).getPrice() + "元");
        return convertView;
    }

    class ViewHolder {
        ImageView chaptersPic;
        TextView name;
        TextView remark;
        TextView price;
    }
}
